<?php
include("../utility/connection.php");
include("../model/mPaper.php");
session_start();

if($_SERVER["REQUEST_METHOD"] == "POST") {
    unset($_SESSION['topikId']);
    unset($_SESSION['topListResult']);
    
    $result = '';
    $count = 0;
    $topikId = trim(mysql_real_escape_string($_POST["hidTopikId"]));
    if (intval($topikId) > 0) {
        $result = fnGetTopListById($topikId);
        $count = mysql_num_rows($result); // number of row
    } else if (intval($topikId) == 0) {
        $result = fnGetTopList();
        $count = mysql_num_rows($result); // number of row
    }
    
    
    if ($count > 0) {
        $_SESSION['topikId']=$topikId;
        $_SESSION['topListResult']='';
        header("location: ../ui/admin/listDokumenAdmin.php");
    } else {
        $_SESSION['topikId']=$topikId;
        unset($_SESSION['topListResult']);
        header("location: ../ui/admin/listDokumenAdmin.php");
    }
}
?>